package com.fish.anne.model;

 import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;

import com.fish.anne.Constants;

 
public class SystemAdminUser extends BaseObject implements Serializable {
    private Long adminId;
    private String username;
    private String userpass;
    private String name;
    private String config;
    private byte adminSuper;
    private String lastIp;
    private Long loginCount;
    private Long lastLogin;
    private boolean status;
    private String adminNo;
    private String department;

    
	private List<SystemAdminRole> systemAdminRoles;
	private String userpassComfirm;
    
    public String getUserpassComfirm() {
		return userpassComfirm;
	}

	public void setUserpassComfirm(String userpassComfirm) {
		this.userpassComfirm = userpassComfirm;
	}

	public List<SystemAdminRole> getSystemAdminRoles() {
		return systemAdminRoles;
	}
	
	public void setSystemAdminRoles(List<SystemAdminRole> systemAdminRoles) {
		this.systemAdminRoles = systemAdminRoles;
	}
	private String oldPassword;
     
    public String getOldPassword() {
		return oldPassword;
	}

	public void setOldPassword(String oldPassword) {
		this.oldPassword = oldPassword;
	}
	private boolean changepwd;
	 
    public boolean isChangepwd() {
		return changepwd;
	}

	public void setChangepwd(boolean changepwd) {
		this.changepwd = changepwd;
	}

 
    
     
    public Long getAdminId() {
        return this.adminId;
    }
    
    public void setAdminId(Long adminId) {
        this.adminId = adminId;
    }
    
    @Column(name="username", nullable=false, length=30)
    public String getUsername() {
        return this.username;
    }
    
    public void setUsername(String username) {
        this.username = username;
    }
    
     public String getUserpass() {
        return this.userpass;
    }
    
    public void setUserpass(String userpass) {
        this.userpass = userpass;
    }
    
     public String getName() {
        return this.name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
     public String getConfig() {
        return this.config;
    }
    
    public void setConfig(String config) {
        this.config = config;
    }
    
     public byte getAdminSuper() {
        return this.adminSuper;
    }
    
    public void setAdminSuper(byte adminSuper) {
        this.adminSuper = adminSuper;
    }
    
    @Column(name="last_ip", nullable=false, length=16)
    public String getLastIp() {
        return this.lastIp;
    }
    
    public void setLastIp(String lastIp) {
        this.lastIp = lastIp;
    }
    
    @Column(name="login_count", nullable=false)
    public Long getLoginCount() {
        return this.loginCount;
    }
    
    public void setLoginCount(Long loginCount) {
        this.loginCount = loginCount;
    }
    
    @Column(name="last_login", nullable=false)
    public Long getLastLogin() {
        return this.lastLogin;
    }
    
    public void setLastLogin(Long lastLogin) {
        this.lastLogin = lastLogin;
    }
    
    @Column(name="status", nullable=false)
    public boolean isStatus() {
        return this.status;
    }
    
    public void setStatus(boolean status) {
        this.status = status;
    }
    
    @Column(name="admin_no", nullable=false, length=50)
    public String getAdminNo() {
        return this.adminNo;
    }
    
    public void setAdminNo(String adminNo) {
        this.adminNo = adminNo;
    }
    
    @Column(name="department", nullable=false, length=50)
    public String getDepartment() {
        return this.department;
    }
    
    public void setDepartment(String department) {
        this.department = department;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        SystemAdminUser pojo = (SystemAdminUser) o;

        if (username != null ? !username.equals(pojo.username) : pojo.username != null) return false;
        if (userpass != null ? !userpass.equals(pojo.userpass) : pojo.userpass != null) return false;
        if (name != null ? !name.equals(pojo.name) : pojo.name != null) return false;
        if (config != null ? !config.equals(pojo.config) : pojo.config != null) return false;
         if (lastIp != null ? !lastIp.equals(pojo.lastIp) : pojo.lastIp != null) return false;
        if (loginCount != null ? !loginCount.equals(pojo.loginCount) : pojo.loginCount != null) return false;
        if (lastLogin != null ? !lastLogin.equals(pojo.lastLogin) : pojo.lastLogin != null) return false;
        if (status != pojo.status) return false;
        if (adminNo != null ? !adminNo.equals(pojo.adminNo) : pojo.adminNo != null) return false;
        if (department != null ? !department.equals(pojo.department) : pojo.department != null) return false;

        return true;
    }

    public int hashCode() {
        int result = 0;
        result = (username != null ? username.hashCode() : 0);
        result = 31 * result + (userpass != null ? userpass.hashCode() : 0);
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (config != null ? config.hashCode() : 0);
         result = 31 * result + (lastIp != null ? lastIp.hashCode() : 0);
        result = 31 * result + (loginCount != null ? loginCount.hashCode() : 0);
        result = 31 * result + (lastLogin != null ? lastLogin.hashCode() : 0);
        result = 31 * result + (status ? 1 : 0);
        result = 31 * result + (adminNo != null ? adminNo.hashCode() : 0);
        result = 31 * result + (department != null ? department.hashCode() : 0);

        return result;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer(getClass().getSimpleName());

        sb.append(" [");
        sb.append("adminId").append("='").append(getAdminId()).append("', ");
        sb.append("username").append("='").append(getUsername()).append("', ");
        sb.append("userpass").append("='").append(getUserpass()).append("', ");
        sb.append("name").append("='").append(getName()).append("', ");
        sb.append("config").append("='").append(getConfig()).append("', ");
        sb.append("adminSuper").append("='").append(getAdminSuper()).append("', ");
        sb.append("lastIp").append("='").append(getLastIp()).append("', ");
        sb.append("loginCount").append("='").append(getLoginCount()).append("', ");
        sb.append("lastLogin").append("='").append(getLastLogin()).append("', ");
        sb.append("status").append("='").append(isStatus()).append("', ");
        sb.append("adminNo").append("='").append(getAdminNo()).append("', ");
        sb.append("department").append("='").append(getDepartment()).append("'");
        sb.append("]");
      
        return sb.toString();
    }
     
    public void init(){
    	this.setConfig(Constants.DEFALT_STRING);

    	this.lastIp  = Constants.DEFALT_STRING;
    	this.lastLogin = System.currentTimeMillis();
    	this.loginCount = Constants.DEFAULT_LONG;
    	
    }

}
